<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<c:import url="/view/admin/include/header/adminHeader.jsp"></c:import>
    <!-- 컨텐츠 부분 -->
	<div id="container">
    	<!-- 왼쪽 메뉴 부분 -->
    	<c:import url="/view/admin/include/left/adminLeft.jsp"></c:import>
        <!-- 왼쪽 메뉴 부분 -->
        <!-- 오른쪽 내용 부분 -->
        <dl>
        	<dd class="path">
        		홈 > 게시판 관리 > 
        		<span class="path_b">
        			<s:if test="%{boardBean.board_code.equals('BD100')}" >공지사항</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD201')}" >윤리경영 Q&A</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD202')}" >준법지원 Q&A</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD203')}" >공정거래 Q&A</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD204')}" >업무지원 Q&A</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD205')}" >법률자문요청</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD206')}" >소송개시요청</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD501')}" >영업 사례해설 Q&A</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD502')}" >설치 사례해설 Q&A</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD503')}" >서비스 사례해설 Q&A</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD301')}" >윤리경영 게시판</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD302')}" >준법지원 게시판</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD303')}" >공정거래 게시판</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD304')}" >업무지원 게시판</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD400')}" >사이버제보 </s:if>
        		</span>
        	</dd>
        </dl>
		<form id="searchForm" action="/admin/qnaList.hcom" method="post" enctype="multipart/form-data">
			<input type="hidden" id="board_code" name="board_code" value="${boardBean.board_code }"/>
			<input type="hidden" id="currentPage" name="currentPage" value="${boardBean.currentPage }" />  
			<input type="hidden" id="open_flag" name="open_flag" value="${boardBean.open_flag}" />    
	        <dl class="board_top">
	            <dd class="result_num f_orange">검색결과  : 총 ${totalCount}건</dd>
	            <dd class="search">
	            	<select id="search" name="search">
	            		<option value="all">전체</option>
			         	<option value="title">제목</option>
	                    <option value="content">내용</option>
	                    <option value="name">질문자</option>
			        </select>&nbsp;
	                <input type="text" id="searchKeyword" name="searchKeyword" style="width:150px;"/>&nbsp;
	                <input type="button" value="검색" id="btnSearch" class="input_btn_search"/>&nbsp;
	                <!-- <input type="button" value="Exel 출력" id="btnOutputExcel" class="input_btn_down"/> -->
	            </dd>
	        </dl>
		</form>	           
        <dl class="content">          
            <dd class="">
            	<table cellspacing="0" cellpadding="0" summary="" >
                	<caption></caption>
                    	 <colgroup>
							<col width="10%;"/>
							<col width="48%;"/>
							<col width="10%;"/>
							<col width="8%;"/>
							<col width="12%;"/>
							<col width="12%;"/>
                         </colgroup>
                    <thead>
                    	<tr>
	                       	<th scope="col" class="table_th_bottom">번호</th>
	                        <th scope="col" class="table_th_bottom">제목</th>
	                        <th scope="col" class="table_th_bottom">질문자</th>
	                        <th scope="col" class="table_th_bottom">답변여부</th>
	                        <th scope="col" class="table_th_bottom">질문일</th>
	                        <th scope="col" class="table_th_bottom">답변일</th>
                        </tr>
                    </thead>
                    <tbody>
                    	<s:if test="%{1 > list.size()}">
                    	<tr>
                    		<td colspan="6">게시물이 없습니다.</td>
                    	<tr>
                    	</s:if>
                    	<s:iterator value="list" status="i">
						<tr>
							<td><s:property value="boardBean.totalCount - #i.count+1" /></td>
							<td style="text-align:left;">
								<a href="/admin/qnaDetail.hcom?board_seq=${board_seq }&board_code=${board_code}">
									<c:choose>
		                           		<c:when test="${title.length() > 30}">
		                           			<c:if test="${open_flag == 'Y'}">
		                           			<strong>${title.substring(0,30)}...</strong>
		                           			</c:if>
		                           			<c:if test="${open_flag != 'Y'}">
		                           			${title.substring(0,30)}...
		                           			</c:if>
		                           		</c:when>
		                           		<c:otherwise>
		                           			<c:if test="${open_flag == 'Y'}">
		                           			<strong>${title}</strong>
		                           			</c:if>
		                           			<c:if test="${open_flag != 'Y'}">
		                           			${title}
		                           			</c:if>
		                           		</c:otherwise>
		                           </c:choose>
								</a>
							</td>
							<td>${mem_name }</td>
							<td>${answer_flag }</td>
							<td>
								<c:choose>
		                        	<c:when test="${write_time.length() > 10}">${write_time.substring(0,10)}</c:when>
		                           	<c:otherwise>${write_time}</c:otherwise>
		                        </c:choose>
		                    </td>
							<td>
								<c:choose>
		                        	<c:when test="${answer_write_time.length() > 10}">${answer_write_time.substring(0,10)}</c:when>
		                           	<c:otherwise>${answer_write_time}</c:otherwise>
		                        </c:choose>
		                    </td>
						</tr>
						</s:iterator>
                    </tbody>
                 </table>
            </dd>
        </dl>
        <dl class="paginate">  	
            <dd>
            	<div class="paginate_complex" >               
					<s:property value="boardBean.pagingStr" escape="false"/>             
               </div>
            </dd>
         </dl>
        <!-- 오른쪽 내용 부분 -->
    </div>
    <!-- 컨텐츠 부분 -->   
<c:import url="/view/admin/include/footer/adminFooter.jsp"></c:import>
<script type="text/javascript">
	$().ready(function(){
		$(".paginate_complex").children("span").click(function(){	
 			$("#pageIndex").val($(this).attr("id"));
 			$("#listForm").submit();
		});	
		
		$("#btnWrite").click(function(){
			location.href="/admin/AD06/ad0603?board_code=${ad06Dto.board_code}";
		});

		$("#btnSearch").click(function(){ 
			if(searchValidate()){
				$("#searchForm").submit();	
			}
		});		
	});
	
	function searchValidate(){
		if($("#searchKeyword").val() == ""){
			alert("검색할 값을 넣어 주세요");
			$("#searchKeyword").focus();
			return false;
		}
		return true;
	}
	function movePage(page){
	$("#currentPage").val(page);
		/* alert($("#currentPage").val()); */
		location.href="/admin/qnaList.hcom?board_code="+$("#board_code").val()+"&currentPage="+$("#currentPage").val();
	}
</script>
